<?php

/**
 * Model base class.
 */
use Entities\User,
    Doctrine\ORM\Configuration,
    Doctrine\ORM\EntityManager;

class Model extends Nette\Object {

    /**
     *
     * @var Nette\DI\Container
     */
    private $container;

    public function __construct(Nette\DI\Container $container) {
        $this->container = $container;
    }

    /**
     * Konfigurace Doctrine2
     * 
     * @return Doctrine\ORM\EntityManager 
     */
    public function createEntityManager() {
        $config = new Configuration();
        $driver = new Doctrine\ORM\Mapping\Driver\XmlDriver($this->container->params['appDir'] . '/models/entities/MappingFiles');
        $config->setMetadataDriverImpl($driver);
        $config->setProxyNamespace('Entities');
        $config->setProxyDir($this->container->params['proxyDir']);
        return EntityManager::create($this->container->params['database'], $config);
    }

}
